<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="body">
            <h2>Lançar Oferta por Disciplina</h2>

            <p:panel styleClass="container_24 clearfix " style="background: none; border: none;"> 
                <h:form id="form" acceptcharset="utf-8">
                    <p:growl id="msg" life="3000" autoUpdate="true" showDetail="false"/>

                    <p class="subtitle">Dados Gerais</p>

                    <p:outputLabel value="Curso:" styleClass="grid_3" for="cursoSelectCheckboxMenu" 
                                   rendered="#{managerCriarOfertaDisciplina.admin}"/>
                    <div class="grid_8" style="#{managerCriarOfertaDisciplina.admin ? '': 'display: none'}">
                        <p:selectOneMenu id="cursoSelectCheckboxMenu"
                                         value="#{managerCriarOfertaDisciplina.curso}" 
                                         label="Selecione o curso" filter="true"
                                         filterMatchMode="contains"
                                         required="true" rendered="#{managerCriarOfertaDisciplina.admin}"
                                         converter="cursoconverter"
                                         caseSensitive="false" panelStyle="width:220px">
                            <f:selectItem itemLabel="" itemValue="" />
                            <f:selectItems value="#{managerCriarOfertaDisciplina.cursos}" var="item" 
                                           itemLabel="#{item.codigo.concat(' - ').concat(item.nome)}" itemValue="#{item}" />  
                            <p:ajax update=":form:disciplinaSelectCheckboxMenu" listener="#{managerCriarOfertaDisciplina.handleMudarDisciplinas()}" />
                        </p:selectOneMenu>
                    </div>

                    <p:outputLabel value="Disciplinas:" styleClass="grid_3" >
                        <span class="ui-outputlabel-rfi">*</span>
                    </p:outputLabel>
                    <div class="grid_8">
                        <p:selectOneMenu id="disciplinaSelectCheckboxMenu"
                                         value="#{managerCriarOfertaDisciplina.disciplina}" 
                                         label="Selecione a(s) disciplina(s)" filter="true"
                                         filterMatchMode="contains"
                                         converter="disciplinaconverter" required="true"
                                         caseSensitive="false" panelStyle="width:290px">
                            <f:selectItem itemLabel="" itemValue="" />
                            <f:selectItems value="#{managerCriarOfertaDisciplina.disciplinas}" 
                                           var="item" itemLabel="#{item.nome}" itemValue="#{item}" />

                            <p:ajax update=":form:docenteSelectCheckboxMenu" listener="#{managerCriarOfertaDisciplina.handleMudarDocente()}" />
                        </p:selectOneMenu>
                    </div>
                    <div class="clear" />

                    <p:outputLabel value="Docente:" styleClass="grid_3" for="docenteSelectCheckboxMenu" />
                    <div class="grid_8">
                        <p:selectOneMenu id="docenteSelectCheckboxMenu"
                                         value="#{managerCriarOfertaDisciplina.docente}" 
                                         filter="true" filterMatchMode="contains"
                                         required="true"
                                         converter="docenteconverter"
                                         caseSensitive="false" panelStyle="width:220px">
                            <f:selectItem itemLabel="" itemValue="" />
                            <f:selectItems value="#{managerCriarOfertaDisciplina.docentes}" var="item" 
                                           itemLabel="#{item.nome}" itemValue="#{item}" />  

                        </p:selectOneMenu>
                    </div>
                    <div class="clear" />

                    <p:outputLabel value="Horário:" styleClass="grid_3" />
                    <div class="grid_4">
                        <p:selectOneMenu id="horarioDiasSemanaSelectCheckboxMenu"
                                         value="#{managerCriarOfertaDisciplina.horarioDiaSemana}"
                                         required="true" converter="horarioconverter"
                                         caseSensitive="false" panelStyle="width:220px">
                            <f:selectItem itemLabel="" itemValue="" />
                            <f:selectItems value="#{managerCriarOfertaDisciplina.horarios()}" var="item" 
                                           itemLabel="#{managerCriarOfertaDisciplina.horarioDiasSemana(item)}" itemValue="#{item}" />
                            
                            <p:ajax update=":form:horarioInicialFinalSelectCheckboxMenu" 
                                    listener="#{managerCriarOfertaDisciplina.handleHorarioInicialFinal()}" />

                        </p:selectOneMenu>
                    </div>
                    <div class="grid_4">
                        <p:selectOneMenu id="horarioInicialFinalSelectCheckboxMenu"
                                         value="#{managerCriarOfertaDisciplina.ofertaDisciplina.horario}"
                                         required="true" converter="horarioconverter"
                                         caseSensitive="false" panelStyle="width:220px">
                            <f:selectItem itemLabel="" itemValue="" />
                            <f:selectItems value="#{managerCriarOfertaDisciplina.horarios}" var="item" 
                                           itemLabel="#{managerCriarOfertaDisciplina.horarioInicialFinal(item)}" itemValue="#{item}" />  

                        </p:selectOneMenu>
                    </div>

                    <div class="clear"/>

                    <p:outputLabel value="Quantidade de Alunos:" styleClass="grid_3" for="qtdAlunoInputText" />
                    <p:inputText id="qtdAlunoInputText" styleClass="grid_3"
                                 value="#{managerCriarOfertaDisciplina.ofertaDisciplina.quantidadeAlunos}" />
                    <div class="clear" />

                    <div class="buttonAction">
                        <p:commandButton value="Salvar" icon="ui-icon-disk" 
                                         actionListener="#{managerCriarOfertaDisciplina.salvar()}" 
                                         update="@form" styleClass="ui-priority-primary"/>
                        <p:button value="Cancelar" icon="ui-icon-circle-close"
                                  href="indexofertadisciplina.xhtml"/>

                    </div>
                </h:form>
            </p:panel> 
        </ui:define>
    </ui:composition>
</html>